The Architecture of Growth
Rust’s collections, such as Vec<T> and String, are not primitive types; they are library-defined structures residing in the std module. This foundation dictates how Rust organizes data via the module system and manages memory through RAII (Resource Acquisition Is Initialization). While simple types live on the stack, collections utilize Heap Storage for dynamic growth, meaning their memory must be explicitly managed through the Drop trait.
Module Resolution & Visibility
The Rust compiler maps the module tree starting at the crate root (src/lib.rs or src/main.rs). A declaration like mod front_of_house; prompts the compiler to search for src/front_of_house.rs or src/front_of_house/mod.rs. Using pub modifiers and re-exports (pub use) allows encapsulated heap-allocated data to be safely interfaced through idiomatic paths.
As soon as a module’s scope ends, the Drop implementation automatically reclaims heap memory: $$Memory_{reclaimed} = \sum Drop(Elements)$$.